home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / russell / gc.lha / real_malloc.c < prev    next >
C/C++ Source or Header  |  1993-03-04  |  843b  |  46 lines

  1. /* We put this here to minimize the risk of inlining. */
  2. /*VARARGS*/
  3. GC_noop() {}
  4.  
  5. # ifdef PCR
  6. /*
  7.  * This definition should go in its own file that includes no other
  8.  * header files.  Otherwise, we risk not getting the underlying system
  9.  * malloc.
  10.  */
  11. # define PCR_NO_RENAME
  12. # include <stdlib.h>
  13.  
  14. # ifdef __STDC__
  15.     char * real_malloc(size_t size)
  16. # else 
  17.     char * real_malloc()
  18.     int size;
  19. # endif
  20. {
  21.     return((char *)malloc(size));
  22. }
  23. #endif /* PCR */
  24.  
  25. # ifdef __OS2__
  26.  
  27. # include <stddef.h>
  28. # define INCL_DOSMEMMGR
  29. # define INCL_DOSERRORS
  30. # include <os2.h>
  31.  
  32. void * os2_alloc(size_t bytes)
  33. {
  34.     void * result;
  35.  
  36.     if (DosAllocMem(&result, bytes, PAG_EXECUTE | PAG_READ |
  37.                         PAG_WRITE | PAG_COMMIT)
  38.             != NO_ERROR) {
  39.     return(0);
  40.     }
  41.     if (result == 0) return(os2_alloc(bytes));
  42.     return(result);
  43. }
  44.  
  45. # endif /* OS2 */
  46.